package com.fire.commit.service.impl;

import com.fire.commit.domain.Report;
import com.fire.commit.mapper.ReportMapper;
import com.fire.commit.service.ReportService;
import com.fire.common.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public Result insertReport(Report report) {
        int i = reportMapper.insertReport(report);
        if(i>0){
            return Result.ok("添加成功");
        }
        return Result.err(501,"添加成功");
    }

    @Override
    public Result deleteReportById(String id) {

        int i = reportMapper.deleteReportById(id);
        if(i>0){
            return Result.ok("删除成功");
        }
        return Result.err(501,"删除成功");
    }

    @Override
    public Result updateReportStatus(Report report) {
        int i = reportMapper.updateReportStatus(report);
        if(i>0){
            return Result.ok("更新成功");
        }
        return Result.err(501,"更新成功");
    }

    @Override
    public List<Report> findAllReports(Report report) {

        return reportMapper.findAllReports(report);
    }

    @Override
    public Result back(Report report) {
        int i = reportMapper.back(report);
        if(i>0){
            return Result.ok("驳回成功");
        }
        return Result.err(501,"驳回成功");
    }
}
